package com.ruoyi.StarStudio.Mapper;

import com.ruoyi.StarStudio.Domain.Tree;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TreeMapper {

    @Select("select * from tree")
    public List<Tree> getAll();

    public List<Tree> getList(Tree tree);  //带搜索查询

    @Select("select * from tree where tree_zoneid = #{zone_id} order by tree_id")
    public List<Tree> getAllByZoneId(Integer zone_id);

    @Select("select * from tree where tree_id = #{tree_id}")
    public Tree getById(Integer tree_id);

    @Insert("insert into tree values (null,#{tree_type}, #{tree_output},#{tree_fertilizer}, #{tree_fertilizertime}, #{tree_illandpests}, #{tree_pesticidetype}, #{tree_pesticidetime}, #{tree_pesticideuse}, #{tree_longitude}, #{tree_latitude}, #{tree_zoneid})")
    @Options(useGeneratedKeys = true, keyProperty = "tree_id", keyColumn = "tree_id")
    public int add(Tree tree);

    @Update("update tree set tree_type=#{tree_type},tree_output=#{tree_output},tree_fertilizer = #{tree_fertilizer},tree_fertilizertime=#{tree_fertilizertime},tree_illandpests=#{tree_illandpests},tree_pesticidetype=#{tree_pesticidetype},tree_pesticidetime=#{tree_pesticidetime},tree_pesticideuse=#{tree_pesticideuse},tree_longitude=#{tree_longitude},tree_latitude=#{tree_latitude},tree_zoneid=#{tree_zoneid}  where tree_id = #{tree_id}")
    public void update(Tree tree);

    @Delete("delete from tree where tree_id = #{tree_id}")
    public void delete(Integer tree_id);

    @Select("select * from tree where tree_longitude = #{tree_longitude} and tree_latitude = #{tree_latitude}")
    public Tree getByLonAndLat(Tree tree);
}